package adv4;

//import java.time.*;
import java.util.*;

public class CalenTest {

	public static void main(String[] args) {
		Calendar c = Calendar.getInstance();
		System.out.println(c);
		Date d = c.getTime();
		long haomiao = c.getTimeInMillis();
		System.out.println(haomiao);
		// >>>get,set,add
		int year = c.get(Calendar.YEAR);
		System.out.println(year + "年");
		int month = c.get(Calendar.MONTH);
		System.out.println((month + 1) + "月");
		int date = c.get(Calendar.DAY_OF_MONTH);
		System.out.println(date + "日");

		int days = c.get(Calendar.DAY_OF_YEAR);
		System.out.println(days);// 262
		int weeks = c.get(Calendar.WEEK_OF_YEAR);
		System.out.println("weeks in year:" + weeks);
		///
		System.out.println(">>>>>>>>>>>>>>>>>");
		c.add(Calendar.DATE, -100);
		System.out.println(c.getTime());
		// roll add 区别
		// roll 只改变当前项的值，不改变上一个
		c.roll(Calendar.MONTH, 30);
		System.out.println(c.getTime());
		// 设置
		c.set(Calendar.HOUR, 130);
		System.out.println("设置130小时后：");
		System.out.println(c.getTime());
	}

}
